
import 'dart:io';

import 'package:common_utils/common_utils.dart';
import 'package:du_application/provide/AffairDetailProvider.dart';
import 'package:du_application/provide/AffairListProvider.dart';
import 'package:du_application/provide/AffairProvider.dart';
import 'package:du_application/provide/AuthProvider.dart';
import 'package:du_application/provide/ClassifyProvider.dart';
import 'package:du_application/provide/CollectProvider.dart';
import 'package:du_application/provide/EvaluateProvider.dart';
import 'package:du_application/provide/GoodsProvider.dart';
import 'package:du_application/provide/IndexProvider.dart';
import 'package:du_application/provide/InfoProvider.dart';
import 'package:du_application/provide/ListProvider.dart';
import 'package:du_application/provide/OrderProvider.dart';

import 'package:easy_alert/easy_alert.dart';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:fluwx/fluwx.dart' as fluwx;

import './pages/HomePage.dart';

import './provide/setting.dart';
import './provide/person.dart';
import 'package:provide/provide.dart';  

import './routes/routes.dart';
import './routes/application.dart';
import 'package:fluro/fluro.dart';

void main() {
  /// System overlays should be drawn with a dark color. Intended for
  /// applications with a light background.

LogUtil.init(isDebug:true);
  WidgetsFlutterBinding.ensureInitialized();
    fluwx.registerWxApi(appId:"wx9ad0c82b3976733a",universalLink:"https://your.univeral.link.com/placeholder/");
   var providers = Providers();
   var setting = SettingProvide();
   var person = PersonProvide();
   var index = IndexProvide();
   var goods = GoodsProvider();
   var classify = ClassProvider();
   var list = ListProvider();
   var info = InfoProvider();
   var auth = AuthProvider();
   var order = OrderProvider();
   var collect = CollectProvider();
   var evaluate = EvaluateProvider();
   var affair = AffairProvider();
   var affairDetail = AffairDetailProvider();
   var affairList = AffairListProvider();



    providers
    ..provide(Provider<SettingProvide>.value(setting))
    ..provide(Provider<PersonProvide>.value(person))
    ..provide(Provider<IndexProvide>.value(index))
    ..provide(Provider<GoodsProvider>.value(goods))
    ..provide(Provider<ListProvider>.value(list))
    ..provide(Provider<InfoProvider>.value(info))
    ..provide(Provider<EvaluateProvider>.value(evaluate))
    ..provide(Provider<AuthProvider>.value(auth))
    ..provide(Provider<OrderProvider>.value(order))
    ..provide(Provider<CollectProvider>.value(collect))
    ..provide(Provider<AffairProvider>.value(affair))
    ..provide(Provider<AffairDetailProvider>.value(affairDetail))
    ..provide(Provider<AffairListProvider>.value(affairList))
    ..provide(Provider<ClassProvider>.value(classify));

    runApp(
  
    ProviderNode(
      child:AlertProvider(
      child: new MyApp(),
      config: new AlertConfig(
        ok: "", 
        cancel: ""),
    ),
      providers: providers,
    ),
  );
   if (Platform.isAndroid) {
    // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后，是为了在渲染后进行set赋值，覆盖状态栏，写在渲染之前MaterialApp组件会覆盖掉这个值。
    SystemUiOverlayStyle systemUiOverlayStyle =
        SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }    
}


class MyApp extends StatelessWidget {
  const MyApp({Key key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Provide.value<AuthProvider>(context).getToken();
    
    final router = Router();
    Routes.configureRoutes(router);
    Application.router=router;
    return MaterialApp(
      title: "du",
      home:HomePage(),
      
   theme: ThemeData(
        primaryColor:Colors.white,
        textTheme:TextTheme(
          display1:  TextStyle(
            color: Colors.black
          ),
        ),
      primaryIconTheme:IconThemeData(
            color: Colors.black
        )
      ),
    );

    

  }
  
  }




